package com.tac.service.mes.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tac.common.result.Result;
import com.tac.dao.mes.FactoryModelingDao;
import com.tac.pojo.mes.FactoryModeling;
import com.tac.service.mes.FactoryModelingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FactoryModelingServiceImpl implements FactoryModelingService {
    @Autowired
    private FactoryModelingDao factoryModelingDao;

    @Override
    public Result<PageInfo<FactoryModeling>> getList(Integer pageNum, Integer pageSize, String name) {
        PageHelper.startPage(pageNum,pageSize);
        List<FactoryModeling> list = factoryModelingDao.getList(name);
        PageInfo<FactoryModeling> factoryModelingPageInfo = new PageInfo<>(list);
        return Result.success(factoryModelingPageInfo);
    }

    @Override
    public Result save(FactoryModeling factoryModeling) {
        Integer integer = factoryModelingDao.save(factoryModeling);
        if(integer<=0){
            return Result.error("添加失败");
        }
        return Result.success(null);
    }

    @Override
    public Result remove(List<Integer> ids) {
        Integer integer = factoryModelingDao.remove(ids);
        if(integer<=0){
            return Result.error("删除失败");
        }
        return Result.success(null);
    }

    @Override
    public Result update(FactoryModeling factoryModeling) {
        Integer integer = factoryModelingDao.update(factoryModeling);
        if(integer<=0){
            return Result.error("更新失败");
        }
        return Result.success(null);
    }
}
